<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets">
    <h:head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Alterar Senha (Consultor) | Eletronorte</title>
        <h:outputStylesheet library="css" name="style.css" />
        <link rel="icon" href="#{request.contextPath}/_img/favicon.ico" type="image/ico" />
    </h:head>

    <h:body>
        <div id="interface">
            <table id="table-header" cellpadding="0" cellspacing="0">
                <!-- TOPO -->
                <tr>
                    <td><ui:include src="/pages/template/header.xhtml" /></td>
                </tr>

                <!--  MENU -->
                <tr>
                    <td><ui:include src="/pages/protected/admin/menu.xhtml" /></td>
                </tr>
            </table>

            <h:form id="form1" enctype="multipart/form-data" style="margin:30px 29px 30px 29px">

                <p:growl id="campoObrigatorio" life="4000" showDetail="false"
                         rendered="#{facesContext.validationFailed == true}" />
                <p:growl for="sucesso" id="sucesso" life="4000" showDetail="true" />
                <p:growl for="atencao" id="atencao" life="4000" showDetail="true" />
                <p:growl for="erro" id="erro" life="4000" showDetail="true" />

                <p:panelGrid style="width:100%">
                    <f:facet name="header">
                        <p:row>
                            <p:column styleClass = "ui-widget-header" colspan="2">
                                ALTERAR SENHA (CONSULTOR)
                            </p:column>
                        </p:row>
                    </f:facet>
                    <p:row>
                        <p:column style="width: 30%;text-align:right">
                            <h:outputLabel for="senha" value="Senha atual:" />
                        </p:column>
                        <p:column style="text-align: left">
                            <p:password id="senha" value="#{usuarioBean.senha}" size="30"
                                        required="true" requiredMessage="O campo Senha Atual é obrigatório!"
                                        validatorMessage="A Senha tem pelo menos 6 dígitos.">
                                <f:validateLength minimum="6" />
                                <p:focus for="senha" />
                            </p:password>
                        </p:column>
                    </p:row>
                    <p:row>
                        <p:column style="text-align: right">
                            <h:outputLabel for="novaSenha" value="Nova Senha:" />
                        </p:column>
                        <p:column style="text-align: left">
                            <p:password id="novaSenha" value="#{usuarioBean.novaSenha}" size="30"
                                        required="true" requiredMessage="O campo Nova Senha é obrigatório!"
                                        feedback="true" promptLabel="Por favor, digite a nova senha"
                                        weakLabel="Fraca" goodLabel="Força Média" strongLabel="Forte"
                                        validatorMessage="A Nova Senha deve ter pelo menos 6 dígitos.">
                                <p:watermark for="novaSenha" value="Pelo menos 6 caracteres" />
                                <f:validateLength minimum="6" />
                            </p:password>
                        </p:column>
                    </p:row>
                    <p:row>
                        <p:column style="text-align: right">
                            <h:outputLabel for="repitaSenha" value="Repita a Nova Senha:" />
                        </p:column>
                        <p:column style="text-align: left">
                            <p:password id="repitaSenha" value="#{usuarioBean.repitaSenha}" size="30"
                                        required="true" requiredMessage="O campo Repita a Nova Senha é obrigatório!"
                                        feedback="true" promptLabel="Por favor, repita a nova senha"
                                        weakLabel="Fraca" goodLabel="Força Média" strongLabel="Forte">
                                <p:watermark for="repitaSenha" value="Repita a nova senha" />
                                <f:validator validatorId="novaSenhaValidator" />
                            </p:password>
                        </p:column>
                    </p:row>
                    <p:row>
                        <p:column colspan="2">
                            <p:commandButton value="Alterar Senha"
                                             action="#{usuarioBean.alterarSenhaConsultor()}"
                                             ajax="true" update=":form1 sucesso atencao erro campoObrigatorio"/>
                        </p:column>
                    </p:row>
                </p:panelGrid>
            </h:form>

            <!-- RODAPE -->
            <table id="table-footer">
                <ui:include src="/pages/template/footer.xhtml" />
            </table>
        </div>

    </h:body>
</html>